package com.agileai.crm.module.mytasks.service;


import java.util.List;

import com.agileai.common.KeyGenerator;
import com.agileai.crm.cxmodule.TaskCycle8ContentManage;
import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.bizmoduler.core.TreeAndContentManageImpl;

public class TaskCycle8ContentManageImpl
        extends TreeAndContentManageImpl
        implements TaskCycle8ContentManage {
    public TaskCycle8ContentManageImpl() {
        super();
        this.columnIdField = "TC_ID";
        this.columnParentIdField = "TC_FID";
        this.columnSortField = "TC_BEGIN";
    }

	@Override
	public void generatPlanRecord(DataParam param) {
		String taskReviewId = KeyGenerator.instance().genKey();
		param.put("TASK_REVIEW_ID", taskReviewId);
		String statementId = this.sqlNameSpace+"."+"generatPlanRecord";
		this.daoHelper.updateRecord(statementId, param);
	}

	@Override
	public List<DataRow> findProPlanVisitRecords(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"findProPlanVisitRecords";
		List<DataRow> rsList = this.daoHelper.queryRecords(statementId, param);
		return rsList;
	}

	@Override
	public List<DataRow> findCustPlanVisitRecords(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"findCustPlanVisitRecords";
		List<DataRow> rsList = this.daoHelper.queryRecords(statementId, param);
		return rsList;
	}
	
	@Override
	public List<DataRow> queryPeriodicTreeRecords(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"queryPeriodicTreeRecords";
		List<DataRow> rsList = this.daoHelper.queryRecords(statementId, param);
		return rsList;
	}

	@Override
	public List<DataRow> queryUnfinishedTaskRecords(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"queryUnfinishedTaskRecords";
		List<DataRow> rsList = this.daoHelper.queryRecords(statementId, param);
		return rsList;
	}

	@Override
	public DataRow getSummaryRecord(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"getSummaryRecord";
		DataRow dataRow = this.daoHelper.getRecord(statementId, param);
		return dataRow;
	}
	
	@Override
	public DataRow getProNumRecord(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"getProNumRecord";
		DataRow dataRow = this.daoHelper.getRecord(statementId, param);
		return dataRow;
	}

	@Override
	public void updateSummaryRecord(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"getVisitTotalRecord";
		DataRow dataRow = this.daoHelper.getRecord(statementId, param);
		long visitTotal =  (Long) dataRow.get("TASK_REVIEW_VISITS_TOTAL");
		param.put("TASK_REVIEW_VISITS_TOTAL", visitTotal);
		
		statementId = this.sqlNameSpace+"."+"getStrangeTotalRecord";
		dataRow = this.daoHelper.getRecord(statementId, param);
		long StrangeTotal =  (Long) dataRow.get("TASK_REVIEW_STRANGE");
		param.put("TASK_REVIEW_STRANGE", StrangeTotal);
		
		statementId = this.sqlNameSpace+"."+"updateSummaryRecord";
		this.daoHelper.updateRecord(statementId, param);

		
	}

	@Override
	public void updatePlanRecord(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"updatePlanRecord";
		this.daoHelper.updateRecord(statementId, param);
	}

	@Override
	public List<DataRow> queryOppRecords(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"queryOppRecords";
		List<DataRow> rsList = this.daoHelper.queryRecords(statementId, param);
		return rsList;
	}

	@Override
	public List<DataRow> queryOrderRecords(DataParam param) {
		String statementId = this.sqlNameSpace+"."+"queryOrderRecords";
		List<DataRow> rsList = this.daoHelper.queryRecords(statementId, param);
		return rsList;
	}

//	@Override
//	public DataRow getTaskReviewRecord(DataParam param) {
//		String statementId = this.sqlNameSpace+"."+"getTaskReviewRecord";
//		DataRow dataRow = this.daoHelper.getRecord(statementId, param);
//		return dataRow;
//	}
}
